package leetCode.offer24;

public class Solution1 implements Solution{


    /**
     * 反转链表，只需要在遍历时修改指针即可
     * @param head
     * @return
     */
    @Override
    public ListNode reverseList(ListNode head) {
        if(head==null) return null;
        ListNode currentNode = head;
        ListNode next = currentNode.next;
        currentNode.next = null;
        while (next!=null){
            ListNode third = next.next;
            next.next = currentNode;
            currentNode = next;
            next = third;
        }
        return currentNode;
    }
}
